package com.gonsin.gview.model.dynamic.form;

import com.gonsin.gview.model.GFormItemModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@ApiModel("文本输入框的描述")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DynamicRichText extends DynamicFormItem {

    @ApiModelProperty("rich_text表示富文本输入框，还有check_box\\file\\radio\\rich_text\\text_input\\tree_check_box\\tree_selector")
    private final String itemType = "rich_text";

    @ApiModelProperty("是否必选")
    private boolean required = true;

    @ApiModelProperty("查询或者提交表单时，表示  ${keyName}=value")
    private String keyName;

    @ApiModelProperty("显示的名字")
    private String name;

    @ApiModelProperty("富文本显示的行数")
    private int column = 3;

    @ApiModelProperty("动态显示的js脚本，用于控制特定情况下该输入框的隐藏和显示")
    private String showIf = "1";

    @ApiModelProperty("根据情况禁用")
    private String disableIf = "0";


    public static DynamicRichTextBuilder builder() {
        return new DynamicRichTextBuilder();
    }

    public static final class DynamicRichTextBuilder {
        @ApiModelProperty("是否必选")
        private boolean required = true;

        @ApiModelProperty("查询或者提交表单时，表示  ${keyName}=value")
        private String keyName;

        @ApiModelProperty("显示的名字")
        private String name;

        @ApiModelProperty("富文本显示的行数")
        private int column = 3;

        @ApiModelProperty("动态显示的js脚本，用于控制特定情况下该输入框的隐藏和显示")
        private String showIf = "1";

        @ApiModelProperty("根据情况禁用")
        private String disableIf = "0";

        private DynamicRichTextBuilder() {
        }

        public DynamicRichTextBuilder required(boolean required) {
            this.required = required;
            return this;
        }

        public DynamicRichTextBuilder keyName(String keyName) {
            this.keyName = keyName;
            return this;
        }

        public DynamicRichTextBuilder name(String name) {
            this.name = name;
            return this;
        }

        public DynamicRichTextBuilder column(int column) {
            this.column = column;
            return this;
        }

        public DynamicRichTextBuilder showIf(String showIf) {
            this.showIf = showIf;
            return this;
        }

        public DynamicRichTextBuilder disableIf(String disableIf) {
            this.disableIf = disableIf;
            return this;
        }

        public DynamicRichText build() {
            DynamicRichText dynamicRichText = new DynamicRichText();
            dynamicRichText.setRequired(required);
            dynamicRichText.setKeyName(keyName);
            dynamicRichText.setName(name);
            dynamicRichText.setColumn(column);
            dynamicRichText.setShowIf(showIf);
            dynamicRichText.setDisableIf(disableIf);
            return dynamicRichText;
        }
    }
}
